trainD = read.csv("EnglishLS.train.csv", header = TRUE, sep = ","
, quote="\"",  na.strings = "NaN")
trainD[1:10,]
testD = read.csv("EnglishLS.test.csv", header = TRUE, sep = ","
, quote="\"",  na.strings = "NaN")
testD[1:10,]
ans = read.csv("EnglishLS.test.key.csv", header = TRUE, sep = ",", 
quote="\"")
ans[1:10,]
testD$sense <- ans$sense
targets = levels(testD$target)

final = c()

for (trg in targets) {
	print(trg)

	D_train = trainD[trainD$target == trg,]
	D_test = testD[testD$target == trg,]


	D_inst = D_test[c(1,2)]
	D_train = D_train [c(-1,-2)]
	D_test = D_test [c(-1,-2)]

	D_train$sense = factor(D_train$sense)

	model = nb.train(D_train)
	pred = nb.predict(D_test,model)


	D_inst$predic =  pred$class.pred

	final = rbind(final, D_inst)
}

write.table(final, file = "EnlishLS.Answers.key", quote = FALSE, sep = " ",
eol = "\n", na = "NA", dec = ".", row.names = FALSE, col.names = FALSE)


write.table(final, file = "../scorer/EnlishLS.Answers.key", quote = FALSE, sep = " ",
eol = "\n", na = "NA", dec = ".", row.names = FALSE, col.names = FALSE)


